package com.test;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpVersion;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.MultipartEntity;
import org.apache.http.entity.mime.content.StringBody;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.CoreProtocolPNames;
import org.apache.http.params.HttpParams;
import org.apache.http.util.EntityUtils;
import org.json.JSONObject;

import android.util.Log;

import com.westcom.basicstruct.LogInStruct;
import com.test.AnalyzeJson;
import com.test.MakeJson;

public class ServerCommunication {
	private MakeJson mkJson;
	private AnalyzeJson anajson;
	private String params;
	private SyncPost post;
    public ServerCommunication() {
	    mkJson = new MakeJson();
	    anajson = new AnalyzeJson();
	    post = SyncPost.getPostInstance();
    }
	public LogInStruct Login(String MailAddress, String MD5PassWord){
        LogInStruct login = null;

		try {
	        params = mkJson.MakeLoginJson(MailAddress, MD5PassWord).toString();  
	        String url = TestHttpActivity.HOST_HTTPADDRESS + "login_normal";
	        String answer = post.addParams(params).postJson(url);
	        if(answer != null && answer != "")
	        	login = anajson.AnalyzeLogin(new JSONObject(answer));
	        return login;

	    } catch (Exception e) {	       
	        return login;
	    }
	}
}

